import random


class Rectangle:
    def __init__(self, width, height):
        self.width = width
        self.height = height

    def get_length(self):
        return 2*(self.width + self.height)

    def get_area(self):
        return self.width * self.height

    def get_sum(self):
        return 2*(self.width + self.height) + self.width * self.height

    def __str__(self):
        return (f"宽{self.width} 高{self.height} "
                f"周长{self.get_length()} 面积{self.get_area()} "
                f"周长与面积和{self.get_sum()}")


# rect = Rectangle(5, 8)
# print(rect)
class RectangleManage:
    def __init__(self):
        self.l = []

    def add_rect(self):
        for i in range(10):
            rect = Rectangle(random.randint(5, 10), random.randint(5, 10))
            d = {
                "宽": rect.width,
                "高": rect.height,
                "周长": rect.get_length(),
                "面积": rect.get_sum(),
                "周长与面积和": rect.get_area()
            }
            self.l.append(d)

    def show_rect(self):
        for e in self.l:
            print(e)

    def get_max_sum(self):
        max_sum = None
        max_sum_rect = []
        for i in range(len(self.l)):
            if max_sum is None:
                max_sum = self.l[i]["周长与面积和"]
            else:
                if max_sum < self.l[i]["周长与面积和"]:
                    max_sum = self.l[i]["周长与面积和"]
        print(f"最大周长与面积和为{max_sum}")
        for i in range(len(self.l)):
            if max_sum == self.l[i]["周长与面积和"]:
                max_sum_rect.append(self.l[i])
        for e in max_sum_rect:
            print(f"周长与面积和最大的矩形：{e}")


def main():
    rm = RectangleManage()
    rm.add_rect()
    rm.show_rect()
    rm.get_max_sum()


main()
